package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/4/23 15:25
 */

@RestController
@RequestMapping("/prod/index")
public class IndexController {

    @Autowired
    TbProdService tbProdService;

    /**
     * @description 分页获取商品列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/23 15:29
     */
    @PostMapping("/getProdList")
    public R getProdList(@RequestBody PageInfoVo pageInfoVo) {
        return  tbProdService.getProdList(pageInfoVo);
    }

    /**
     * @description 添加商品
     * @params [tbProd]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/24 15:06
     */
    @PostMapping("/addProd")
    public R addProd(@RequestBody TbProd tbProd) {
        return  tbProdService.addProd(tbProd);

    }

    /**
     * @description 获取字典列表
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/24 15:06
     */
    @PostMapping("/getDictList/{typeId}")
    public R getDictList(@PathVariable("typeId") Integer typeId) {
        return  tbProdService.getDictList(typeId);
    }

    /**
     * @description 删除商品
     * @params [prodId]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/24 16:18
     */
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable("prodId") Integer prodId) {
        return  tbProdService.deleteProd(prodId);
    }

    /**
     * @description 商品修改
     * @params [tbProd]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/25 10:15
     */
    @PostMapping("/updateProd")
    public R updateProd(@RequestBody TbProd tbProd) {
        return  tbProdService.updateProd(tbProd);
    }

    /**
     * @description 发送Kafka测试消息
     * @params [msg]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/28 9:17
     */
    @PostMapping("/sendMessage/{msg}")
    public R sendMessage(@PathVariable("msg") String msg) {
        return  tbProdService.sendMessage(msg);
    }

    /**
     * @description 修改商品状态（商品审核）
     * @params [tbProd]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/28 9:17
     */
    @PostMapping("/changeProdStatus")
    public R changeProdStatus(@RequestBody TbProd tbProd) {
        return  tbProdService.changeProdStatus(tbProd);
    }

}
